import ajax from './ajax'

/**
 *
 * 获取订单列表
 * @returns {*}
 */
export function getOrderList(searchObj) {
  return ajax.get(`/api/sys/order/${searchObj.type}/orders`, {
    params: searchObj
  })
}

/**
 * 设置订单价格
 */
export function updateOrderPrice(orderId, price) {
  let url = `/api/order/${orderId}`
  return ajax.post(url, { price })
}

/**
 * 获取该产品可服务的业务员
 */
export function getAvaliableEmployees(searchObj) {
  let url = `/api/service/${searchObj.id}/employees`
  return ajax.get(url, { params: { location: searchObj.location } })
}

/**
 * 为订单分配业务员
 * @param updateObj
 */
export function updateOrderEmployee(updateObj) {
  let url = `/api/order/distribute/${updateObj.orderId}`
  return ajax.put(url, { employeeId: updateObj.employeeId })
}

/**
 * 订单服务列表
 */
export function getOrderTasks(orderId) {
  let url = `/api/order/task/${orderId}`
  return ajax.get(url)
}

/**
 * 手动更新订单支付状态
 */
export function updatePayStatus(params) {
  console.log(`updatePayStatus called!`)
  let url = `/api/admin/order/pay/${params.orderId}`
  return ajax.put(url, { remark: params.remark, fee: params.fee })
}
/**
 * 给订单分配新的业务员
 */
export function assginEmployeeForOrder(orderId, empId) {
  let url = `/api/order/distribute/${orderId}`
  return ajax.put(url, { employeeId: empId })
}
/**
 * 分配订单给管理员
 */
export function assignOrderToAdmin(orderId, adminId) {
  let url = `/api/sys/order/assign/${orderId}/${adminId}`
  return ajax.get(url)
}
/**
 * 订单分配获取订单列表
 */
export function getAssignOrderList(params) {
  let url = `/api/order/assign/orders`
  return ajax.get(url, { params })
}
/**
 * 管理员检验订单
 */
export function checkOrder(checkId, status, remark) {
  let url = `/api/sys/order/check/${checkId}`
  return ajax.put(url, { status, remark })
}
